<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Models\Candy\Story;
use Models\Candy\Tech;

class CreateCandyStoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = "CREATE TABLE `".Story::getFullTableTable()."` (
  `".Story::DB_FIELD_ID."` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `".Story::DB_FIELD_DATE."` date NOT NULL COMMENT '日期',
  `".Story::DB_FIELD_TITLE."` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
  `".Story::DB_FIELD_CONTENT."` varchar(255) DEFAULT '' COMMENT '文本内容',
  `".Story::DB_FIELD_STORY_TYPE."` tinyint(4) NOT NULL DEFAULT '1' COMMENT '故事类型1图片2视频3图集',
  `".Story::DB_FIELD_MEDIA_SOURCE."` tinyint(4) NOT NULL DEFAULT '1' COMMENT '媒体来源1阿里云2url',
  `".Story::DB_FIELD_MEDIA_CONTENT."` varchar(255) NOT NULL DEFAULT '' COMMENT '媒体内容',
  `".Story::DB_FIELD_IS_PRIVATE."` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否私密',
  `".Story::DB_FIELD_CREATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `".Story::DB_FIELD_UPDATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `".Story::DB_FIELD_DELETED_AT."` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `idx_date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='糖果故事表';";
        DB::connection()->getPdo()->exec($sql);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop(Story::getFullTableTable());
    }
}
